from django.db import models
from django.contrib.auth.models import User

SIMPLE_STATUS_INACTIVE   = 0
SIMPLE_STATUS_ACTIVE = 1
SIMPLE_STATUS_CHOICES = (
        (SIMPLE_STATUS_INACTIVE, u'Inactive'),
        (SIMPLE_STATUS_ACTIVE,   u'Active'),
    )

class Country(models.Model):
    name = models.CharField(max_length=80)
    status = models.IntegerField(choices=SIMPLE_STATUS_CHOICES)
    
    class Meta:
        ordering = ("name",)
        verbose_name = u'Country'
        verbose_name_plural = u'Countries'
    
    def __unicode__(self):
        return self.name

class VisaOffice(models.Model):
    country = models.ForeignKey(Country)
    name = models.CharField(max_length=80)
    address = models.CharField(max_length=100)
    status = models.IntegerField(choices=SIMPLE_STATUS_CHOICES)
    
    class Meta:
        ordering = ("name",)
        verbose_name = u'Visa office'
        verbose_name_plural = u'Visa offices'
    
    def __unicode__(self):
        return self.name

class CaipsRequest(models.Model):
    user = models.ForeignKey(User)
    visa_office = models.ForeignKey(VisaOffice)
    file_no = models.CharField(max_length=15)
    email = models.EmailField(blank=True)
    date_requested = models.DateTimeField(auto_now_add=True)
    date_updated = models.DateTimeField(auto_now=True)
    status = models.CharField(max_length=10)
    is_paid = models.BooleanField()
    amount_paid = models.DecimalField(max_digits=14, decimal_places=4, blank=True)
    payment_method = models.CharField(max_length=20, blank=True)
    # caips_form = models.FileField()
    
    def __unicode__(self):
        return self.file_no

class ApplicantType(models.Model):
    name = models.CharField(max_length=45)
    status = models.IntegerField(choices=SIMPLE_STATUS_CHOICES)
    
    def __unicode__(self):
        return self.name

class ConsentForm(models.Model):
    request = models.ForeignKey(CaipsRequest)
    applicant_type = models.ForeignKey(ApplicantType)
    first_name = models.CharField(max_length=45)
    middle_name = models.CharField(max_length=45, blank=True)
    last_name = models.CharField(max_length=45)
    dirthdate = models.DateField()
    # consent_form = models.FileField()
    
    def __unicode__(self):
        return u'%s %s' % (self.first_name, self.last_name,)

